home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / ACL / Animation Class Library / Headers / AnimObject.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-01  |  4.5 KB  |  165 lines  |  [TEXT/MPCC]

  1.  
  2. /********************************************
  3.  **** Animation Class Library V1.0 © 1994 Yves Schmid & Alia Development
  4.  ****
  5.  **** AnimObject.h
  6.  ****
  7.  **** Created:      01 June 1994
  8.  **** Modified:     01 September 1994
  9.  **** Version:      0
  10.  **** Compatible:   C++, Mac System 7
  11.  ****
  12.  **** Description:  • Anim class is an abstract class which defines the base
  13.  ****                of an animation object. If you want to create a new kind of
  14.  ****                animation you should override this class. 
  15.  ****
  16.  ****                • Anim is a child class of the AnimSupervisor class.
  17.  ****
  18.  *******************/
  19.  
  20. #ifndef AnimObject_H
  21. #define AnimObject_H
  22.  
  23.  
  24. #include "AnimSupervisor.h"
  25.  
  26. class AnimBase;
  27. class Anim;
  28.  
  29. class AnimObject: public AnimSupervisor
  30. {
  31.  
  32.     //***********************************************************
  33.     //.............. P U B L I C   M E T H O D S.................
  34.  
  35.     public:
  36.  
  37.     AnimObject(AnimSupervisor *base);
  38.     ~AnimObject(void);
  39.  
  40.     // Changing the supervisor
  41.     void setanimsupervisor(AnimSupervisor *base);
  42.  
  43.     // Gets superanim, returns NULL if there is no superanim (if supervisor is an AnimBase)
  44.     AnimObject *getsuperanim(void);
  45.  
  46.     inline void setdeletenextupdate(const Boolean d) {delnextupdate = d;}
  47.     inline Boolean getdeletenextupdate(void) const {return delnextupdate;}
  48.                                             // If TRUE this animation object will be
  49.                                             // deleted at the next update
  50.  
  51.  
  52.     inline float getx(void) const {return x;}     // Finds position
  53.     inline float gety(void) const {return y;}
  54.  
  55.     inline float &getoldx(void) {return oldx;}     // Gets/Sets old position
  56.     inline float &getoldy(void) {return oldy;}
  57.  
  58.     inline void place(float ax, float ay)        // Places object to a new position 
  59.     {                                            // (sets oldx and oldy to x and y)
  60.         oldx = x = ax;
  61.         oldy = y = ay;
  62.     }
  63.  
  64.     inline void move(float deltax, float deltay)    // Moves object with deltas
  65.     {                                                // (sets oldx and oldy to the previous position)
  66.         oldx = x;    oldy = y;
  67.         x+=deltax;    y+=deltay;
  68.     }
  69.     
  70.     virtual void findmaxsize(short *width, short *height) const; 
  71.                                                      // Finds the maximum pixels size of the
  72.                                                      // object.
  73.                                                      // You can pass NULL pointers.     
  74.  
  75.     virtual void findcurrect(Rect *rect); // Finds the visual rect of the
  76.                                           // object in his current state.
  77.  
  78.  
  79.     virtual void findcursize(short *width, short *height);          
  80.                                         // Finds the maximum pixels size of the
  81.                                         // object in his current state. 
  82.                                         // You can pass NULL pointers.     
  83.  
  84.     virtual void findabsxy(short *gx, short *gy);
  85.     virtual void findabsxy(float *gx, float *gy);
  86.                                         // Finds the absolute position of the object. Very
  87.                                         // useful when you have objects which have relative
  88.                                         // positions (subanims for example).
  89.                                         // You can pass NULL pointers.     
  90.  
  91.     
  92.     // Gets/sets sorting priority. (Default is 0).
  93.     inline short getpriority(void) const {return priority;} 
  94.     inline void setpriority(const short p) {priority = p;} 
  95.  
  96.  
  97.     // Gets/sets collision keys
  98.     inline unsigned long getcollisionkey_me(void) const {return collisionkey_me;}   
  99.     inline unsigned long getcollisionkey_hit(void) const {return collisionkey_hit;}
  100.  
  101.     inline void setcollisionkey_me(const unsigned long m) {collisionkey_me = m;}  
  102.     inline void setcollisionkey_hit(const unsigned long h) {collisionkey_hit = h;}
  103.  
  104.  
  105.     virtual Boolean checkcollision(AnimObject *);    
  106.                                             // If there is a collision between this animation
  107.                                            // and the passed animation returns TRUE. 
  108.                                           // The collisionkeys of the two animations are ANDed ("hit" key
  109.                                          // is ANDed with the "me" key).
  110.                                         // If the result of the AND is zero, checkcollision returns
  111.                                        // FALSE without checking collision at a more
  112.                                       // elaborated level.
  113.  
  114.  
  115.  
  116.  
  117.     //***********************************************************
  118.  
  119.     //..........................................................
  120.     // You should not call the following methods!
  121.  
  122.     virtual Boolean draw(short basex =0, short basey =0); 
  123.     virtual Boolean mustbemasked(void) const;   
  124.  
  125.     virtual void getcollisionmask(BitMap **b, unsigned long **lmask, Rect *);    
  126.  
  127.     virtual void process_submasking(AnimBase *base, Rect *maskrect);    
  128.  
  129.  
  130.     //..........................................................
  131.  
  132.  
  133.     protected:
  134.  
  135.  
  136.     short        priority;    
  137.  
  138.  
  139.     virtual void processcontrols(void);    
  140.  
  141.  
  142.     virtual AnimObject *drawsubanims(Boolean neg, AnimObject *start, short basex, short basey); 
  143.  
  144.  
  145.     private:
  146.  
  147.     unsigned long collisionkey_me;        
  148.     unsigned long collisionkey_hit;    
  149.  
  150.     Boolean        delnextupdate;        
  151.                                     
  152.  
  153.     float         x,y;            
  154.     float        oldx,oldy;            
  155.  
  156.  
  157.     virtual void privfindabsxy(float *gx, float *gy);
  158.     virtual void privfindabsxy(short *gx, short *gy);        
  159. };
  160.  
  161.  
  162.  
  163. #endif
  164.  
  165.